package com.yang.test;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import com.corundumstudio.socketio.Configuration;
import com.corundumstudio.socketio.SocketIOServer;
import com.corundumstudio.socketio.store.RedissonStoreFactory;

public class SockerIOServer {
	public static void main(String[] args) {
		
		new Thread(new Runnable() {
			public void run() {
				Config redissonConfig = new Config();
				redissonConfig.useSingleServer().setAddress("172.16.80.212:6379").setPassword("02062000");
				// Instantiate Redisson connection
				RedissonClient redisson = Redisson.create(redissonConfig);
				// Instantiate RedissonClientStoreFactory
				RedissonStoreFactory redisStoreFactory = new RedissonStoreFactory(redisson);
				// Instantiate SocketIO Configuration
				Configuration config = new Configuration();
				config.setHostname("localhost");
				config.setPort(3000);
				config.setStoreFactory(redisStoreFactory);
				// Instantiate SocketIO Server
				SocketIOServer server = new SocketIOServer(config);
				server.addListeners(new SocketEventIOHandler(server,redisson));
				server.start();
			}
		}).start();
	}
}
